var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
//此代码由机器自动生成，请不要手动修改
var WpfTest;
(function (WpfTest) {
    var BLL;
    (function (BLL) {
        let TestService_;
        (function (TestService_) {
            //js通讯回调
            function OnResponse(msgId, response) {
                response = decodeURI(response);
                response = unescape(response);
                return response;
            }
            //js通道异步封装
            function TneQueryAsync(msgId, request) {
                return __awaiter(this, void 0, void 0, function* () {
                    return new Promise((resolve, reject) => {
                        //调用原始callback的js通讯接口
                        request = escape(request);
                        mbQuery(msgId, request, (id, response) => {
                            resolve(OnResponse(id, response));
                        });
                    });
                });
            }
            TestService_.TneQueryAsync = TneQueryAsync;
            class ServiceInvokeInfo {
            }
            TestService_.ServiceInvokeInfo = ServiceInvokeInfo;
        })(TestService_ || (TestService_ = {}));
        class TestService {
            Add(x, Update) {
                return __awaiter(this, void 0, void 0, function* () {
                    let serviceInvokeInfo = new TestService_.ServiceInvokeInfo();
                    serviceInvokeInfo.ServicePath = "WpfTest.BLL.ITestService,WpfTest";
                    serviceInvokeInfo.MethodName = "Add";
                    serviceInvokeInfo.Args = new Array();
                    if (x instanceof Function) {
                        window.Tne_TestService_Add_896555 = x;
                        function x_(json) {
                            json = decodeURI(json);
                            json = unescape(json);
                            let args = JSON.parse(json);
                            let jsr = new Object();
                            try {
                                jsr.Result = window.Tne_TestService_Add_896555(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
                                delete (window.Tne_TestService_Add_896555);
                                jsr.Status = true;
                                jsr.ErrorMessage = "null";
                            }
                            catch (err) {
                                jsr.Result == "WpfTest.BLL.TestService.Add";
                                jsr.Status = false;
                                jsr.ErrorMessage = err;
                            }
                            let rjson = JSON.stringify(jsr);
                            return escape(rjson);
                        }
                        serviceInvokeInfo.Args.push(x_.toString());
                    }
                    else {
                        serviceInvokeInfo.Args.push(x);
                    }
                    if (Update instanceof Function) {
                        window.Tne_TestService_Add_598883 = Update;
                        function Update_(json) {
                            json = decodeURI(json);
                            json = unescape(json);
                            let args = JSON.parse(json);
                            let jsr = new Object();
                            try {
                                jsr.Result = window.Tne_TestService_Add_598883(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
                                delete (window.Tne_TestService_Add_598883);
                                jsr.Status = true;
                                jsr.ErrorMessage = "null";
                            }
                            catch (err) {
                                jsr.Result == "WpfTest.BLL.TestService.Add";
                                jsr.Status = false;
                                jsr.ErrorMessage = err;
                            }
                            let rjson = JSON.stringify(jsr);
                            return escape(rjson);
                        }
                        serviceInvokeInfo.Args.push(Update_.toString());
                    }
                    else {
                        serviceInvokeInfo.Args.push(Update);
                    }
                    let request = JSON.stringify(serviceInvokeInfo);
                    let resultJson = yield TestService_.TneQueryAsync(8262020, request);
                    let result = JSON.parse(resultJson);
                    if (result.Status == true) {
                        return result.Result;
                    }
                    else {
                        throw result;
                    }
                });
            }
        }
        BLL.TestService = TestService;
    })(BLL = WpfTest.BLL || (WpfTest.BLL = {}));
})(WpfTest || (WpfTest = {}));
//此代码由机器自动生成，请不要手动修改
var WpfTest;
(function (WpfTest) {
    var Entity;
    (function (Entity) {
        let UserInfo_;
        (function (UserInfo_) {
            //js通讯回调
            function OnResponse(msgId, response) {
                response = decodeURI(response);
                response = unescape(response);
                return response;
            }
            //js通道异步封装
            function TneQueryAsync(msgId, request) {
                return __awaiter(this, void 0, void 0, function* () {
                    return new Promise((resolve, reject) => {
                        //调用原始callback的js通讯接口
                        request = escape(request);
                        mbQuery(msgId, request, (id, response) => {
                            resolve(OnResponse(id, response));
                        });
                    });
                });
            }
            UserInfo_.TneQueryAsync = TneQueryAsync;
            class ServiceInvokeInfo {
            }
            UserInfo_.ServiceInvokeInfo = ServiceInvokeInfo;
        })(UserInfo_ || (UserInfo_ = {}));
        class UserInfo {
            set Name(value) { this.Name_ = value; }
            get Name() { return this.Name_; }
            set Age(value) { this.Age_ = value; }
            get Age() { return this.Age_; }
        }
        Entity.UserInfo = UserInfo;
    })(Entity = WpfTest.Entity || (WpfTest.Entity = {}));
})(WpfTest || (WpfTest = {}));
///<reference path="../BLL/TestService.cs.ts">
function Show() {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            let win = window;
            let testService = new WpfTest.BLL.TestService();
            let r = yield testService.Add(1, (userList) => {
                alert(userList.length);
                for (var i = 0; i < userList.length; i++) {
                    alert(userList[i].Name);
                    alert(userList[i].Age);
                    return true;
                }
            });
        }
        catch (err) {
            alert(err.ErrorMessage);
        }
    });
}
